package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.model.user.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.SessionAttribute;
import org.springframework.web.bind.annotation.SessionAttributes;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 李旭
 * @date 2022/1/5 15:48
 * @Description:
 */
@Controller
public class TestController {










    //第一个请求
    @GetMapping("/hello")
    public String hello(Model model,  HttpSession session){
        model.addAttribute("world","世界你好");
        List<String> list = new ArrayList<>();
        list.add("刘");
        list.add("刘华强");
        list.add("成龙");
        model.addAttribute("list",list);
        model.addAttribute("num",11);//数字类型
        //Session
        session.setAttribute("person","哈哈");
        model.addAttribute("gname","<span style=\"color:green\">宝强</span>");


       /* List<UserInfo> userInfoList = new ArrayList<>();;
        userInfoList.stream().map(UserInfo :: getEmail);*/

        return "hello";
    }
    @GetMapping("/h")
    public String h(Model model,  @SessionAttribute(name = "person") HttpSession session){
        model.addAttribute("world","世界你好");

        List<String> list = new ArrayList<>();
        list.add("刘");
        list.add("刘华强");
        list.add("成龙");
        model.addAttribute("list",list);
        model.addAttribute("num",11);//数字类型

        //Session
        session.setAttribute("person","哈哈");
        return "hello";
    }
}
